<!DOCTYPE HTML>
<html>

	<head>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<title>科创研究成果平台</title>
		<link href="css/main.css" rel="stylesheet" />
		<link href="css/style.css" rel="stylesheet" />
		<link href="../bootstrap/dist/css/bootstrap.css" rel="stylesheet" />
		<script src="../js/jquery-2.1.0.min.js" type="text/javascript"></script>
		<script src="js/jquery.SuperSlide.2.1.1.js"></script>
		<script type="text/javascript" src="../bootstrap/dist/js/bootstrap.js"></script>
		<script src="js/common.js" type="text/javascript"></script>
		<link rel="stylesheet" href="../kindeditor-4.1.10/themes/default/default.css"/>
	    <script charset="utf-8" src="../kindeditor-4.1.10/kindeditor-all.js"></script>
	    <script charset="utf-8" src="../kindeditor-4.1.10/lang/zh_CN.js"></script>
	    <link rel="stylesheet" href="../bootstrapvalidator/css/bootstrapValidator.css"/>
	    <script type="text/javascript" src="../bootstrapvalidator/js/bootstrapValidator.js"></script>
	    <script type="text/javascript" src="../bootstrapvalidator/js/language/zh_CN.js"></script>
		<style type="text/css">
		.holy-grail {
		    margin: 0 auto;
		    max-width: 1240px;
		    width: 100%;
		    margin-top: 100px;
		}
		.card2 .card-header {
		    display: -ms-flexbox;
		    display: flex;
		    -ms-flex-align: center;
		    align-items: center;
		    margin: 0;
		    padding-left: 26px;
		    height: 60px;
		    font-size: 20px;
		    font-weight: 700;
		    background-color: #f4f8fd;
		    border-bottom: 1px solid #e9eef2;
		    color: #6e7a81;
		}
		.account-layout-body {
		    display: -ms-flexbox;
		    display: flex;
		}
		.account-navbar-container {
		    width: 180px;
		    min-width: 180px;
		}
		.list {
		    width: 130px;
		}
		.list-header {
		    font-size: 22px;
		    color: #1183f2;
		}
		.list-item {
		    padding-top: 8px;
		    padding-bottom: 8px;
		    font-size: 16px;
		    margin: 5px;
		    border-bottom: 1px solid #eee;
		}
		.list-item a {
		    padding-top: 8px;
		    padding-bottom: 8px;
		    color: #333;
		}
		.account-child-layout {
		    -ms-flex-positive: 1;
		    flex-grow: 1;
		    overflow: hidden;
		    margin-bottom: 50px;
		}
		</style>
	</head>

	<body style="background-color: #fff">
		<!--头部-->
		<header>
			<div class="beijing">
				<h2 style="font-weight:bold;font-size: 18px;">
		<a href="index.html" style="text-decoration : none"><em>
		<font color="white">科创研究成果平台</font></em></a>
		</h2>
				<ul>
					<li>
						<a class="menu_1 " style="text-decoration : none" href="index.html">首页</a>
					</li>
					<li>
						<a class="menu_1 " style="text-decoration : none" href="news.html">资讯<em></em></a>
					</li>
					<li>
						<a class="menu_1 " style="text-decoration : none" href="act.html">活动<em></em></a>
					</li>
					<li>
						<a class="menu_1 " style="text-decoration : none" href="tech.html">技术<em></em></a>
					</li>
					<li>
						<a class="menu_1 " style="text-decoration : none" href="cooper.html">合作<em></em></a>
					</li>
					<li>
						<a class="menu_1 hover" style="text-decoration : none" href="person.html">个人中心<em></em></a>
					</li>
				</ul>
				<div class="clear"></div>
			</div>
			<div class="clear"></div>
		</header>

		<div class="holy-grail">
			<div class="personal-index-container">
				<div class="account-layout-body">
					<div class="account-navbar-container">
						<ul class="list">
							<li class="list-header">
								全部功能
							</li>
							<li class="list-item">
								<a href="person.html" >
									发布的技术
								</a>
							</li>
							<li class="list-item">
								<a href="person_requires.html" class="" >
									发布的需求
								</a>
							</li>
							<li class="list-item">
                                <a href="person_consult.html" >
                                                                                          咨询的需求
                                </a>
                            </li>
							<li class="list-item">
								<a href="person_act.html">
									报名的活动
								</a>
							</li>
							<li class="list-item">
								<a href="person_sendrequire.html"  >
									发布新需求
								</a>
							</li>
							<li class="list-item">
								<a href="person_sendtech.html" style="color: #1183f2;">
									发布新技术
								</a>
							</li>
							<li class="list-item">
								<a href="person_userinfo.html" class="">
									设置
								</a>
							</li>
						</ul>
					</div>
					<div class="technologies-index-container account-create-technologies-container account-child-layout">
						<div class="technology-body">
							<div class="card2 technology-list">
								<h3 class="card-header title">
									发布新技术
								</h3>
								<div class="card-body" style="margin-top: 20px;">
									<form id="reqform">
		                                  <div class="form-group">
										    <label>技术编号</label>
										    <input type="text" name="technicalNo" class="form-control" id="technicalNo" placeholder="技术编号">
										  </div>
										  <div class="form-group">
                                            <label>技术名称</label>
                                            <input type="text" name="name" class="form-control" id="name" placeholder="技术名称">
                                          </div>
                                          <div class="form-group">
                                            <label>技术应用范围</label>
                                            <input type="text" name="range" class="form-control" id="range" placeholder="技术应用范围">
                                          </div>
                                          <div class="form-group">
                                            <label>合作价格</label>
                                            <input type="number" name="price" class="form-control" id="price" placeholder="技术应用范围">
                                          </div>
                                          <div class="form-group">
                                            <label>交付形式</label>
                                            <input type="text" name="payform" class="form-control" id="payform" placeholder="交付形式">
                                          </div>
                                          <div class="form-group">
                                            <label>专利状态</label>
                                            <input type="text" name="patent" class="form-control" id="patent" placeholder="交付形式">
                                          </div>
										  <div class="form-group">
										    <label>技术背景</label>
										    <textarea id="background"
                                                style="width:100%;height:200px;visibility:hidden;">
                                            </textarea>
										  </div>
										  <div class="form-group">
                                            <label>技术介绍</label>
                                            <textarea id="introduction" 
                                                style="width:100%;height:200px;visibility:hidden;">
                                            </textarea>
                                          </div>
                                          <div class="form-group">
                                            <label>技术优势</label>
                                            <textarea id="advantage" 
                                                style="width:100%;height:200px;visibility:hidden;">
                                            </textarea>
                                          </div>
                                          <div class="form-group">
                                            <label>应用影响</label>
                                            <textarea id="effect" 
                                                style="width:100%;height:200px;visibility:hidden;">
                                            </textarea>
                                          </div>
										  <div class="form-group">
                                            <label>成熟度</label>
                                            <select id="maturity" class="form-control">
                                            <option value='小试'>小试</option>
                                            <option value='中试'>中试</option>
                                            <option value='生试'>生试</option>
                                            </select>
                                          </div>
                                          <div class="form-group">
                                            <label>来源地</label>
                                            <input type="text" class="form-control" id="source" name="source">
                                          </div>
                                          <div class="form-group">
                                            <label>所属领域</label>
                                            <select id="areaid" class="form-control">
										    </select>
                                          </div>
										  <button type="button" id="btn-submit" class="btn btn-primary">确认发布</button>
		                            </form>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
            
	</body>

</html>
<script type="text/javascript">
	$(document).ready(function() {
		var userid=getCookie("userid");
        if(userid==''||userid==null){
            //跳转到登录、注册页面
            window.location.href="login.html";
        }
	})
	
	
	
	$(function () {
		//var backgroundEditor;
		//var introductionEditor;
		//var advantageEditor;
		//var effectEditor;
        //详情编辑器
        KindEditor.ready(function (K) {
            this.backgroundEditor = K.create('textarea[id="background"]', {
                items: ['source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code', 'cut', 'copy', 'paste',
                    'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
                    'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
                    'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/',
                    'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
                    'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|',
                    'table', 'hr', 'emoticons', 'baidumap', 'pagebreak',
                    'anchor', 'link', 'unlink'],
            });
            
            this.introductionEditor = K.create('textarea[id="introduction"]', {
                items: ['source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code', 'cut', 'copy', 'paste',
                    'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
                    'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
                    'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/',
                    'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
                    'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|',
                    'table', 'hr', 'emoticons', 'baidumap', 'pagebreak',
                    'anchor', 'link', 'unlink'],
            });
            
            this.advantageEditor= K.create('textarea[id="advantage"]', {
                items: ['source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code', 'cut', 'copy', 'paste',
                    'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
                    'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
                    'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/',
                    'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
                    'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|',
                    'table', 'hr', 'emoticons', 'baidumap', 'pagebreak',
                    'anchor', 'link', 'unlink'],
            });
            
            this.effectEditor= K.create('textarea[id="effect"]', {
                items: ['source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code', 'cut', 'copy', 'paste',
                    'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
                    'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
                    'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/',
                    'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
                    'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|',
                    'table', 'hr', 'emoticons', 'baidumap', 'pagebreak',
                    'anchor', 'link', 'unlink'],
            });
        });
        
        
        //请求所有领域数据
        $.post("/areatype/search",function(res){
        	for(let i=0;i<res.rows.length;i++){
	        	$("#areaid").append(`<option value='${res.rows[i].id}'>${res.rows[i].name}</option>`);
        	}
        })
    });
	
    $(function () {
        $("#reqform").bootstrapValidator({
            live: 'enabled',//验证时机，enabled是内容有变化就验证（默认），disabled和submitted是提交再验证
            excluded: [':disabled', ':hidden', ':not(:visible)'],//排除无需验证的控件，比如被禁用的或者被隐藏的
            submitButtons: '#btn-submit',//指定提交按钮，如果验证失败则变成disabled，但我没试成功，反而加了这句话非submit按钮也会提交到action指定页面
            message: 'not null',//好像从来没出现过
            feedbackIcons: {//根据验证结果显示的各种图标
                valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            },
            fields: {
            	name: {
                    validators: {
                        notEmpty: {//检测非空,radio也可用
                            message: '必须输入'
                        }
                    }
                },
                technicalNo: {
                    validators: {
                        notEmpty: {//检测非空,radio也可用
                            message: '必须输入'
                        }
                    }
                },
                range:{
	                validators: {
	                    notEmpty: {//检测非空,radio也可用
	                        message: '必须输入'
	                    }
	                }
	            },
	            price:{
	            	 validators: {
	                        notEmpty: {//检测非空,radio也可用
	                            message: '必须输入'
	                        }
	                    }
	            },
	            payform:{
	            	validators: {
                        notEmpty: {//检测非空,radio也可用
                            message: '必须输入'
                        }
                    }
	            },
	            patent:{
                    validators: {
                        notEmpty: {//检测非空,radio也可用
                            message: '必须输入'
                        }
                    }
                },
                maturity:{
                    validators: {
                        notEmpty: {//检测非空,radio也可用
                            message: '必须输入'
                        }
                    }
                },
                source:{
                	validators: {
                        notEmpty: {//检测非空,radio也可用
                            message: '必须输入'
                        }
                    }
                }
            }
        });
        $("#btn-submit").click(function () {//非submit按钮点击后进行验证，如果是submit则无需此句直接验证
            $("#reqform").bootstrapValidator('validate');//提交验证
            if ($("#reqform").data('bootstrapValidator').isValid()) {//获取验证结果，如果成功，执行下面代码
                //验证成功后的操作
                //var data=JSON.stringify($('#reqform').serialize());
                var data={"technicalNo":$("#technicalNo").val(),
                		"createUserid":getCookie("userid"),"name":$("#name").val(),
                		"range":$("#range").val(),"price":$("#price").val(),
                		"payform":$("#payform").val(),"patent":$("#patent").val(),
                		"background":backgroundEditor.html(),"introduction":introductionEditor.html(),
                		"advantage":advantageEditor.html(),"effect":effectEditor.html(),
                		"maturity":$("#maturity").val(),"source":$("#source").val(),
                		"areaid":$("#areaid").val(),"status":0
                		};
                $.ajax({
                    type: "POST",
                    url: "/achievement/insert",
                    data: JSON.stringify(data),
                    dataType: "json",
                    contentType:"application/json",
                    success: function(data){
                       window.location.href="person.html";
                    }
               });
            }
        });
    });

</script>
